<!-- HTML header for doxygen 1.8.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<title>OpenCV: samples/cpp/stitching_detailed.cpp</title>
<link href="../../opencv.ico" rel="shortcut icon" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="../../tutorial-utils.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
//<![CDATA[
MathJax.Hub.Config(
{
  TeX: {
      Macros: {
          matTT: [ "\\[ \\left|\\begin{array}{ccc} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{array}\\right| \\]", 9],
          fork: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ \\end{array} \\right.", 4],
          forkthree: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ \\end{array} \\right.", 6],
          forkfour: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ #7 & \\mbox{#8}\\\\ \\end{array} \\right.", 8],
          vecthree: ["\\begin{bmatrix} #1\\\\ #2\\\\ #3 \\end{bmatrix}", 3],
          vecthreethree: ["\\begin{bmatrix} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{bmatrix}", 9],
          cameramatrix: ["#1 = \\begin{bmatrix} f_x & 0 & c_x\\\\ 0 & f_y & c_y\\\\ 0 & 0 & 1 \\end{bmatrix}", 1],
          distcoeffs: ["(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \\tau_x, \\tau_y]]]]) \\text{ of 4, 5, 8, 12 or 14 elements}"],
          distcoeffsfisheye: ["(k_1, k_2, k_3, k_4)"],
          hdotsfor: ["\\dots", 1],
          mathbbm: ["\\mathbb{#1}", 1],
          bordermatrix: ["\\matrix{#1}", 1]
      }
  }
}
);
//]]>
</script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<!--#include virtual="/google-search.html"-->
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../opencv-logo-small.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">OpenCV
   &#160;<span id="projectnumber">4.5.2</span>
   </div>
   <div id="projectbrief">Open Source Computer Vision</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('../../',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">samples/cpp/stitching_detailed.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<p>A detailed example on image stitching</p>
<div class="fragment"><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;fstream&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div><div class="line"><span class="preprocessor">#include &quot;opencv2/opencv_modules.hpp&quot;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="../../d1/d4e/utility_8hpp.html">opencv2/core/utility.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../d6/d87/imgcodecs_8hpp.html">opencv2/imgcodecs.hpp</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../d4/dd5/highgui_8hpp.html">opencv2/highgui.hpp</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../d3/d45/autocalib_8hpp.html">opencv2/stitching/detail/autocalib.hpp</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../d9/d88/blenders_8hpp.html">opencv2/stitching/detail/blenders.hpp</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../d8/d46/timelapsers_8hpp.html">opencv2/stitching/detail/timelapsers.hpp</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../d0/d8a/camera_8hpp.html">opencv2/stitching/detail/camera.hpp</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../df/d70/exposure__compensate_8hpp.html">opencv2/stitching/detail/exposure_compensate.hpp</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../d3/dc9/matchers_8hpp.html">opencv2/stitching/detail/matchers.hpp</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../d3/d73/motion__estimators_8hpp.html">opencv2/stitching/detail/motion_estimators.hpp</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../d1/d74/seam__finders_8hpp.html">opencv2/stitching/detail/seam_finders.hpp</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../dc/de7/detail_2warpers_8hpp.html">opencv2/stitching/detail/warpers.hpp</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../da/d64/warpers_8hpp.html">opencv2/stitching/warpers.hpp</a>&quot;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#ifdef HAVE_OPENCV_XFEATURES2D</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../dc/daa/xfeatures2d_8hpp.html">opencv2/xfeatures2d.hpp</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../dc/dcb/nonfree_8hpp.html">opencv2/xfeatures2d/nonfree.hpp</a>&quot;</span></div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"></div><div class="line"><span class="preprocessor">#define ENABLE_LOG 1</span></div><div class="line"><span class="preprocessor">#define LOG(msg) std::cout &lt;&lt; msg</span></div><div class="line"><span class="preprocessor">#define LOGLN(msg) std::cout &lt;&lt; msg &lt;&lt; std::endl</span></div><div class="line"></div><div class="line"><span class="keyword">using namespace </span><a class="code" href="../../d8/dcc/namespacestd.html">std</a>;</div><div class="line"><span class="keyword">using namespace </span><a class="code" href="../../d2/d75/namespacecv.html">cv</a>;</div><div class="line"><span class="keyword">using namespace </span><a class="code" href="../../d2/daf/namespacecv_1_1detail.html">cv::detail</a>;</div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> printUsage(<span class="keywordtype">char</span>** argv)</div><div class="line">{</div><div class="line">    cout &lt;&lt;</div><div class="line">        <span class="stringliteral">&quot;Rotation model images stitcher.\n\n&quot;</span></div><div class="line">         &lt;&lt; argv[0] &lt;&lt; <span class="stringliteral">&quot; img1 img2 [...imgN] [flags]\n\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;Flags:\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --preview\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Run stitching in the preview mode. Works faster than usual mode,\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      but output image will have lower resolution.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --try_cuda (yes|no)\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Try to use CUDA. The default value is &#39;no&#39;. All default values\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      are for CPU mode.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;\nMotion Estimation Flags:\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --work_megapix &lt;float&gt;\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Resolution for image registration step. The default is 0.6 Mpx.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --features (surf|orb|sift|akaze)\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Type of features used for images matching.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      The default is surf if available, orb otherwise.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --matcher (homography|affine)\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Matcher used for pairwise image matching.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --estimator (homography|affine)\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Type of estimator used for transformation estimation.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --match_conf &lt;float&gt;\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Confidence for feature matching step. The default is 0.65 for surf and 0.3 for orb.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --conf_thresh &lt;float&gt;\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Threshold for two images are from the same panorama confidence.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      The default is 1.0.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --ba (no|reproj|ray|affine)\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Bundle adjustment cost function. The default is ray.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --ba_refine_mask (mask)\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Set refinement mask for bundle adjustment. It looks like &#39;x_xxx&#39;,\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      where &#39;x&#39; means refine respective parameter and &#39;_&#39; means don&#39;t\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      refine one, and has the following format:\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      &lt;fx&gt;&lt;skew&gt;&lt;ppx&gt;&lt;aspect&gt;&lt;ppy&gt;. The default mask is &#39;xxxxx&#39;. If bundle\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      adjustment doesn&#39;t support estimation of selected parameter then\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      the respective flag is ignored.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --wave_correct (no|horiz|vert)\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Perform wave effect correction. The default is &#39;horiz&#39;.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --save_graph &lt;file_name&gt;\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Save matches graph represented in DOT language to &lt;file_name&gt; file.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Labels description: Nm is number of matches, Ni is number of inliers,\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      C is confidence.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;\nCompositing Flags:\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --warp (affine|plane|cylindrical|spherical|fisheye|stereographic|compressedPlaneA2B1|compressedPlaneA1.5B1|compressedPlanePortraitA2B1|compressedPlanePortraitA1.5B1|paniniA2B1|paniniA1.5B1|paniniPortraitA2B1|paniniPortraitA1.5B1|mercator|transverseMercator)\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Warp surface type. The default is &#39;spherical&#39;.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --seam_megapix &lt;float&gt;\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Resolution for seam estimation step. The default is 0.1 Mpx.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --seam (no|voronoi|gc_color|gc_colorgrad)\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Seam estimation method. The default is &#39;gc_color&#39;.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --compose_megapix &lt;float&gt;\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Resolution for compositing step. Use -1 for original resolution.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      The default is -1.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --expos_comp (no|gain|gain_blocks|channels|channels_blocks)\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Exposure compensation method. The default is &#39;gain_blocks&#39;.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --expos_comp_nr_feeds &lt;int&gt;\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Number of exposure compensation feed. The default is 1.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --expos_comp_nr_filtering &lt;int&gt;\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Number of filtering iterations of the exposure compensation gains.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Only used when using a block exposure compensation method.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      The default is 2.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --expos_comp_block_size &lt;int&gt;\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      BLock size in pixels used by the exposure compensator.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Only used when using a block exposure compensation method.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      The default is 32.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --blend (no|feather|multiband)\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Blending method. The default is &#39;multiband&#39;.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --blend_strength &lt;float&gt;\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Blending strength from [0,100] range. The default is 5.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --output &lt;result_img&gt;\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      The default is &#39;result.jpg&#39;.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --timelapse (as_is|crop) \n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      Output warped images separately as frames of a time lapse movie, with &#39;fixed_&#39; prepended to input file names.\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;  --rangewidth &lt;int&gt;\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;      uses range_width to limit number of images to match with.\n&quot;</span>;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// Default command line args</span></div><div class="line">vector&lt;String&gt; img_names;</div><div class="line"><span class="keywordtype">bool</span> preview = <span class="keyword">false</span>;</div><div class="line"><span class="keywordtype">bool</span> try_cuda = <span class="keyword">false</span>;</div><div class="line"><span class="keywordtype">double</span> work_megapix = 0.6;</div><div class="line"><span class="keywordtype">double</span> seam_megapix = 0.1;</div><div class="line"><span class="keywordtype">double</span> compose_megapix = -1;</div><div class="line"><span class="keywordtype">float</span> conf_thresh = 1.f;</div><div class="line"><span class="preprocessor">#ifdef HAVE_OPENCV_XFEATURES2D</span></div><div class="line"><span class="keywordtype">string</span> features_type = <span class="stringliteral">&quot;surf&quot;</span>;</div><div class="line"><span class="keywordtype">float</span> match_conf = 0.65f;</div><div class="line"><span class="preprocessor">#else</span></div><div class="line"><span class="keywordtype">string</span> features_type = <span class="stringliteral">&quot;orb&quot;</span>;</div><div class="line"><span class="keywordtype">float</span> match_conf = 0.3f;</div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"><span class="keywordtype">string</span> matcher_type = <span class="stringliteral">&quot;homography&quot;</span>;</div><div class="line"><span class="keywordtype">string</span> estimator_type = <span class="stringliteral">&quot;homography&quot;</span>;</div><div class="line"><span class="keywordtype">string</span> ba_cost_func = <span class="stringliteral">&quot;ray&quot;</span>;</div><div class="line"><span class="keywordtype">string</span> ba_refine_mask = <span class="stringliteral">&quot;xxxxx&quot;</span>;</div><div class="line"><span class="keywordtype">bool</span> do_wave_correct = <span class="keyword">true</span>;</div><div class="line"><a class="code" href="../../d7/d74/group__stitching__rotation.html#ga83b24d4c3e93584986a56d9e43b9cf7f">WaveCorrectKind</a> wave_correct = <a name="a0"></a><a class="code" href="../../d7/d74/group__stitching__rotation.html#gga83b24d4c3e93584986a56d9e43b9cf7faa9e3a58207a58e3245aab95af18b68a9">detail::WAVE_CORRECT_HORIZ</a>;</div><div class="line"><span class="keywordtype">bool</span> save_graph = <span class="keyword">false</span>;</div><div class="line">std::string save_graph_to;</div><div class="line"><span class="keywordtype">string</span> warp_type = <span class="stringliteral">&quot;spherical&quot;</span>;</div><div class="line"><span class="keywordtype">int</span> expos_comp_type = ExposureCompensator::GAIN_BLOCKS;</div><div class="line"><span class="keywordtype">int</span> expos_comp_nr_feeds = 1;</div><div class="line"><span class="keywordtype">int</span> expos_comp_nr_filtering = 2;</div><div class="line"><span class="keywordtype">int</span> expos_comp_block_size = 32;</div><div class="line"><span class="keywordtype">string</span> seam_find_type = <span class="stringliteral">&quot;gc_color&quot;</span>;</div><div class="line"><span class="keywordtype">int</span> blend_type = Blender::MULTI_BAND;</div><div class="line"><span class="keywordtype">int</span> timelapse_type = Timelapser::AS_IS;</div><div class="line"><span class="keywordtype">float</span> blend_strength = 5;</div><div class="line"><span class="keywordtype">string</span> result_name = <span class="stringliteral">&quot;result.jpg&quot;</span>;</div><div class="line"><span class="keywordtype">bool</span> timelapse = <span class="keyword">false</span>;</div><div class="line"><span class="keywordtype">int</span> range_width = -1;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">int</span> parseCmdArgs(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>** argv)</div><div class="line">{</div><div class="line">    <span class="keywordflow">if</span> (argc == 1)</div><div class="line">    {</div><div class="line">        printUsage(argv);</div><div class="line">        <span class="keywordflow">return</span> -1;</div><div class="line">    }</div><div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i &lt; argc; ++i)</div><div class="line">    {</div><div class="line">        <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--help&quot;</span> || <span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;/?&quot;</span>)</div><div class="line">        {</div><div class="line">            printUsage(argv);</div><div class="line">            <span class="keywordflow">return</span> -1;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--preview&quot;</span>)</div><div class="line">        {</div><div class="line">            preview = <span class="keyword">true</span>;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--try_cuda&quot;</span>)</div><div class="line">        {</div><div class="line">            <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;no&quot;</span>)</div><div class="line">                try_cuda = <span class="keyword">false</span>;</div><div class="line">            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;yes&quot;</span>)</div><div class="line">                try_cuda = <span class="keyword">true</span>;</div><div class="line">            <span class="keywordflow">else</span></div><div class="line">            {</div><div class="line">                cout &lt;&lt; <span class="stringliteral">&quot;Bad --try_cuda flag value\n&quot;</span>;</div><div class="line">                <span class="keywordflow">return</span> -1;</div><div class="line">            }</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--work_megapix&quot;</span>)</div><div class="line">        {</div><div class="line">            work_megapix = atof(argv[i + 1]);</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--seam_megapix&quot;</span>)</div><div class="line">        {</div><div class="line">            seam_megapix = atof(argv[i + 1]);</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--compose_megapix&quot;</span>)</div><div class="line">        {</div><div class="line">            compose_megapix = atof(argv[i + 1]);</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--result&quot;</span>)</div><div class="line">        {</div><div class="line">            result_name = argv[i + 1];</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--features&quot;</span>)</div><div class="line">        {</div><div class="line">            features_type = argv[i + 1];</div><div class="line">            <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(features_type) == <span class="stringliteral">&quot;orb&quot;</span>)</div><div class="line">                match_conf = 0.3f;</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--matcher&quot;</span>)</div><div class="line">        {</div><div class="line">            <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;homography&quot;</span> || <span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;affine&quot;</span>)</div><div class="line">                matcher_type = argv[i + 1];</div><div class="line">            <span class="keywordflow">else</span></div><div class="line">            {</div><div class="line">                cout &lt;&lt; <span class="stringliteral">&quot;Bad --matcher flag value\n&quot;</span>;</div><div class="line">                <span class="keywordflow">return</span> -1;</div><div class="line">            }</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--estimator&quot;</span>)</div><div class="line">        {</div><div class="line">            <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;homography&quot;</span> || <span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;affine&quot;</span>)</div><div class="line">                estimator_type = argv[i + 1];</div><div class="line">            <span class="keywordflow">else</span></div><div class="line">            {</div><div class="line">                cout &lt;&lt; <span class="stringliteral">&quot;Bad --estimator flag value\n&quot;</span>;</div><div class="line">                <span class="keywordflow">return</span> -1;</div><div class="line">            }</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--match_conf&quot;</span>)</div><div class="line">        {</div><div class="line">            match_conf = <span class="keyword">static_cast&lt;</span><span class="keywordtype">float</span><span class="keyword">&gt;</span>(atof(argv[i + 1]));</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--conf_thresh&quot;</span>)</div><div class="line">        {</div><div class="line">            conf_thresh = <span class="keyword">static_cast&lt;</span><span class="keywordtype">float</span><span class="keyword">&gt;</span>(atof(argv[i + 1]));</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--ba&quot;</span>)</div><div class="line">        {</div><div class="line">            ba_cost_func = argv[i + 1];</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--ba_refine_mask&quot;</span>)</div><div class="line">        {</div><div class="line">            ba_refine_mask = argv[i + 1];</div><div class="line">            <span class="keywordflow">if</span> (ba_refine_mask.size() != 5)</div><div class="line">            {</div><div class="line">                cout &lt;&lt; <span class="stringliteral">&quot;Incorrect refinement mask length.\n&quot;</span>;</div><div class="line">                <span class="keywordflow">return</span> -1;</div><div class="line">            }</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--wave_correct&quot;</span>)</div><div class="line">        {</div><div class="line">            <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;no&quot;</span>)</div><div class="line">                do_wave_correct = <span class="keyword">false</span>;</div><div class="line">            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;horiz&quot;</span>)</div><div class="line">            {</div><div class="line">                do_wave_correct = <span class="keyword">true</span>;</div><div class="line">                wave_correct = <a class="code" href="../../d7/d74/group__stitching__rotation.html#gga83b24d4c3e93584986a56d9e43b9cf7faa9e3a58207a58e3245aab95af18b68a9">detail::WAVE_CORRECT_HORIZ</a>;</div><div class="line">            }</div><div class="line">            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;vert&quot;</span>)</div><div class="line">            {</div><div class="line">                do_wave_correct = <span class="keyword">true</span>;</div><div class="line">                wave_correct = <a name="a1"></a><a class="code" href="../../d7/d74/group__stitching__rotation.html#gga83b24d4c3e93584986a56d9e43b9cf7fa3d3661394e07da0c7c51ddeb84851212">detail::WAVE_CORRECT_VERT</a>;</div><div class="line">            }</div><div class="line">            <span class="keywordflow">else</span></div><div class="line">            {</div><div class="line">                cout &lt;&lt; <span class="stringliteral">&quot;Bad --wave_correct flag value\n&quot;</span>;</div><div class="line">                <span class="keywordflow">return</span> -1;</div><div class="line">            }</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--save_graph&quot;</span>)</div><div class="line">        {</div><div class="line">            save_graph = <span class="keyword">true</span>;</div><div class="line">            save_graph_to = argv[i + 1];</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--warp&quot;</span>)</div><div class="line">        {</div><div class="line">            warp_type = string(argv[i + 1]);</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--expos_comp&quot;</span>)</div><div class="line">        {</div><div class="line">            <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;no&quot;</span>)</div><div class="line">                expos_comp_type = ExposureCompensator::NO;</div><div class="line">            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;gain&quot;</span>)</div><div class="line">                expos_comp_type = ExposureCompensator::GAIN;</div><div class="line">            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;gain_blocks&quot;</span>)</div><div class="line">                expos_comp_type = ExposureCompensator::GAIN_BLOCKS;</div><div class="line">            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;channels&quot;</span>)</div><div class="line">                expos_comp_type = ExposureCompensator::CHANNELS;</div><div class="line">            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;channels_blocks&quot;</span>)</div><div class="line">                expos_comp_type = ExposureCompensator::CHANNELS_BLOCKS;</div><div class="line">            <span class="keywordflow">else</span></div><div class="line">            {</div><div class="line">                cout &lt;&lt; <span class="stringliteral">&quot;Bad exposure compensation method\n&quot;</span>;</div><div class="line">                <span class="keywordflow">return</span> -1;</div><div class="line">            }</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--expos_comp_nr_feeds&quot;</span>)</div><div class="line">        {</div><div class="line">            expos_comp_nr_feeds = atoi(argv[i + 1]);</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--expos_comp_nr_filtering&quot;</span>)</div><div class="line">        {</div><div class="line">            expos_comp_nr_filtering = atoi(argv[i + 1]);</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--expos_comp_block_size&quot;</span>)</div><div class="line">        {</div><div class="line">            expos_comp_block_size = atoi(argv[i + 1]);</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--seam&quot;</span>)</div><div class="line">        {</div><div class="line">            <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;no&quot;</span> ||</div><div class="line">                <span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;voronoi&quot;</span> ||</div><div class="line">                <span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;gc_color&quot;</span> ||</div><div class="line">                <span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;gc_colorgrad&quot;</span> ||</div><div class="line">                <span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;dp_color&quot;</span> ||</div><div class="line">                <span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;dp_colorgrad&quot;</span>)</div><div class="line">                seam_find_type = argv[i + 1];</div><div class="line">            <span class="keywordflow">else</span></div><div class="line">            {</div><div class="line">                cout &lt;&lt; <span class="stringliteral">&quot;Bad seam finding method\n&quot;</span>;</div><div class="line">                <span class="keywordflow">return</span> -1;</div><div class="line">            }</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--blend&quot;</span>)</div><div class="line">        {</div><div class="line">            <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;no&quot;</span>)</div><div class="line">                blend_type = Blender::NO;</div><div class="line">            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;feather&quot;</span>)</div><div class="line">                blend_type = Blender::FEATHER;</div><div class="line">            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;multiband&quot;</span>)</div><div class="line">                blend_type = Blender::MULTI_BAND;</div><div class="line">            <span class="keywordflow">else</span></div><div class="line">            {</div><div class="line">                cout &lt;&lt; <span class="stringliteral">&quot;Bad blending method\n&quot;</span>;</div><div class="line">                <span class="keywordflow">return</span> -1;</div><div class="line">            }</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--timelapse&quot;</span>)</div><div class="line">        {</div><div class="line">            timelapse = <span class="keyword">true</span>;</div><div class="line"></div><div class="line">            <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;as_is&quot;</span>)</div><div class="line">                timelapse_type = Timelapser::AS_IS;</div><div class="line">            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;crop&quot;</span>)</div><div class="line">                timelapse_type = Timelapser::CROP;</div><div class="line">            <span class="keywordflow">else</span></div><div class="line">            {</div><div class="line">                cout &lt;&lt; <span class="stringliteral">&quot;Bad timelapse method\n&quot;</span>;</div><div class="line">                <span class="keywordflow">return</span> -1;</div><div class="line">            }</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--rangewidth&quot;</span>)</div><div class="line">        {</div><div class="line">            range_width = atoi(argv[i + 1]);</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--blend_strength&quot;</span>)</div><div class="line">        {</div><div class="line">            blend_strength = <span class="keyword">static_cast&lt;</span><span class="keywordtype">float</span><span class="keyword">&gt;</span>(atof(argv[i + 1]));</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--output&quot;</span>)</div><div class="line">        {</div><div class="line">            result_name = argv[i + 1];</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span></div><div class="line">            img_names.push_back(argv[i]);</div><div class="line">    }</div><div class="line">    <span class="keywordflow">if</span> (preview)</div><div class="line">    {</div><div class="line">        compose_megapix = 0.6;</div><div class="line">    }</div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])</div><div class="line">{</div><div class="line"><span class="preprocessor">#if ENABLE_LOG</span></div><div class="line">    <a class="code" href="../../d1/d1b/group__core__hal__interface.html#ga7cde0074dfd288f2d70c0e035dacb28a">int64</a> app_start_time = <a name="a2"></a><a class="code" href="../../db/de0/group__core__utils.html#gae73f58000611a1af25dd36d496bf4487">getTickCount</a>();</div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"></div><div class="line"><span class="preprocessor">#if 0</span></div><div class="line">    <a name="a3"></a><a class="code" href="../../db/de0/group__core__utils.html#gae4904ef072dede53cf161d9a6869083f">cv::setBreakOnError</a>(<span class="keyword">true</span>);</div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"></div><div class="line">    <span class="keywordtype">int</span> retval = parseCmdArgs(argc, argv);</div><div class="line">    <span class="keywordflow">if</span> (retval)</div><div class="line">        <span class="keywordflow">return</span> retval;</div><div class="line"></div><div class="line">    <span class="comment">// Check if have enough images</span></div><div class="line">    <span class="keywordtype">int</span> num_images = <span class="keyword">static_cast&lt;</span><span class="keywordtype">int</span><span class="keyword">&gt;</span>(img_names.size());</div><div class="line">    <span class="keywordflow">if</span> (num_images &lt; 2)</div><div class="line">    {</div><div class="line">        LOGLN(<span class="stringliteral">&quot;Need more images&quot;</span>);</div><div class="line">        <span class="keywordflow">return</span> -1;</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordtype">double</span> work_scale = 1, seam_scale = 1, compose_scale = 1;</div><div class="line">    <span class="keywordtype">bool</span> is_work_scale_set = <span class="keyword">false</span>, is_seam_scale_set = <span class="keyword">false</span>, is_compose_scale_set = <span class="keyword">false</span>;</div><div class="line"></div><div class="line">    LOGLN(<span class="stringliteral">&quot;Finding features...&quot;</span>);</div><div class="line"><span class="preprocessor">#if ENABLE_LOG</span></div><div class="line">    <a class="code" href="../../d1/d1b/group__core__hal__interface.html#ga7cde0074dfd288f2d70c0e035dacb28a">int64</a> t = <a class="code" href="../../db/de0/group__core__utils.html#gae73f58000611a1af25dd36d496bf4487">getTickCount</a>();</div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"></div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga6395ca871a678020c4a31fadf7e8cc63">Ptr&lt;Feature2D&gt;</a> finder;</div><div class="line">    <span class="keywordflow">if</span> (features_type == <span class="stringliteral">&quot;orb&quot;</span>)</div><div class="line">    {</div><div class="line">        finder = ORB::create();</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (features_type == <span class="stringliteral">&quot;akaze&quot;</span>)</div><div class="line">    {</div><div class="line">        finder = AKAZE::create();</div><div class="line">    }</div><div class="line"><span class="preprocessor">#ifdef HAVE_OPENCV_XFEATURES2D</span></div><div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (features_type == <span class="stringliteral">&quot;surf&quot;</span>)</div><div class="line">    {</div><div class="line">        finder = xfeatures2d::SURF::create();</div><div class="line">    }</div><div class="line"><span class="preprocessor">#endif</span></div><div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (features_type == <span class="stringliteral">&quot;sift&quot;</span>)</div><div class="line">    {</div><div class="line">        finder = SIFT::create();</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        cout &lt;&lt; <span class="stringliteral">&quot;Unknown 2D features type: &#39;&quot;</span> &lt;&lt; features_type &lt;&lt; <span class="stringliteral">&quot;&#39;.\n&quot;</span>;</div><div class="line">        <span class="keywordflow">return</span> -1;</div><div class="line">    }</div><div class="line"></div><div class="line">    <a name="_a4"></a><a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> full_img, img;</div><div class="line">    vector&lt;ImageFeatures&gt; features(num_images);</div><div class="line">    vector&lt;Mat&gt; images(num_images);</div><div class="line">    vector&lt;Size&gt; full_img_sizes(num_images);</div><div class="line">    <span class="keywordtype">double</span> seam_work_aspect = 1;</div><div class="line"></div><div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; num_images; ++i)</div><div class="line">    {</div><div class="line">        full_img = <a name="a5"></a><a class="code" href="../../d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56">imread</a>(<a name="a6"></a><a class="code" href="../../d6/dba/group__core__utils__samples.html#ga3a33b00033b46c698ff6340d95569c13">samples::findFile</a>(img_names[i]));</div><div class="line">        full_img_sizes[i] = full_img.<a name="a7"></a><a class="code" href="../../d3/d63/classcv_1_1Mat.html#a146f8e8dda07d1365a575ab83d9828d1">size</a>();</div><div class="line"></div><div class="line">        <span class="keywordflow">if</span> (full_img.<a name="a8"></a><a class="code" href="../../d3/d63/classcv_1_1Mat.html#abbec3525a852e77998aba034813fded4">empty</a>())</div><div class="line">        {</div><div class="line">            LOGLN(<span class="stringliteral">&quot;Can&#39;t open image &quot;</span> &lt;&lt; img_names[i]);</div><div class="line">            <span class="keywordflow">return</span> -1;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">if</span> (work_megapix &lt; 0)</div><div class="line">        {</div><div class="line">            img = full_img;</div><div class="line">            work_scale = 1;</div><div class="line">            is_work_scale_set = <span class="keyword">true</span>;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span></div><div class="line">        {</div><div class="line">            <span class="keywordflow">if</span> (!is_work_scale_set)</div><div class="line">            {</div><div class="line">                work_scale = <a name="a9"></a><a class="code" href="../../d7/dcc/group__core__utils__softfloat.html#gac48df53b8fd34b87e7b121fa8fd4c379">min</a>(1.0, <a name="a10"></a><a class="code" href="../../d0/de1/group__core.html#ga9070b6a3f093dd952d973819b06f4906">sqrt</a>(work_megapix * 1e6 / full_img.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#a146f8e8dda07d1365a575ab83d9828d1">size</a>().area()));</div><div class="line">                is_work_scale_set = <span class="keyword">true</span>;</div><div class="line">            }</div><div class="line">            <a name="a11"></a><a class="code" href="../../d5/df1/group__imgproc__hal__functions.html#ga2fe39d2201b12e1b961ca56b2aff9ff2">resize</a>(full_img, img, <a name="a12"></a><a class="code" href="../../dc/d84/group__core__basic.html#ga346f563897249351a34549137c8532a0">Size</a>(), work_scale, work_scale, <a name="a13"></a><a class="code" href="../../da/d54/group__imgproc__transform.html#gga5bb5a1fea74ea38e1a5445ca803ff121ac00f4a8155563cdc23437fc0959da935">INTER_LINEAR_EXACT</a>);</div><div class="line">        }</div><div class="line">        <span class="keywordflow">if</span> (!is_seam_scale_set)</div><div class="line">        {</div><div class="line">            seam_scale = <a class="code" href="../../d7/dcc/group__core__utils__softfloat.html#gac48df53b8fd34b87e7b121fa8fd4c379">min</a>(1.0, <a class="code" href="../../d0/de1/group__core.html#ga9070b6a3f093dd952d973819b06f4906">sqrt</a>(seam_megapix * 1e6 / full_img.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#a146f8e8dda07d1365a575ab83d9828d1">size</a>().area()));</div><div class="line">            seam_work_aspect = seam_scale / work_scale;</div><div class="line">            is_seam_scale_set = <span class="keyword">true</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <a name="a14"></a><a class="code" href="../../df/d8c/group__stitching__match.html#ga1e4ca67941780b89a36003eed2bb476e">computeImageFeatures</a>(finder, img, features[i]);</div><div class="line">        features[i].img_idx = i;</div><div class="line">        LOGLN(<span class="stringliteral">&quot;Features in image #&quot;</span> &lt;&lt; i+1 &lt;&lt; <span class="stringliteral">&quot;: &quot;</span> &lt;&lt; features[i].keypoints.size());</div><div class="line"></div><div class="line">        <a class="code" href="../../d5/df1/group__imgproc__hal__functions.html#ga2fe39d2201b12e1b961ca56b2aff9ff2">resize</a>(full_img, img, <a class="code" href="../../dc/d84/group__core__basic.html#ga346f563897249351a34549137c8532a0">Size</a>(), seam_scale, seam_scale, <a class="code" href="../../da/d54/group__imgproc__transform.html#gga5bb5a1fea74ea38e1a5445ca803ff121ac00f4a8155563cdc23437fc0959da935">INTER_LINEAR_EXACT</a>);</div><div class="line">        images[i] = img.<a name="a15"></a><a class="code" href="../../d3/d63/classcv_1_1Mat.html#adff2ea98da45eae0833e73582dd4a660">clone</a>();</div><div class="line">    }</div><div class="line"></div><div class="line">    full_img.<a name="a16"></a><a class="code" href="../../d3/d63/classcv_1_1Mat.html#ae48d4913285518e2c21a3457017e716e">release</a>();</div><div class="line">    img.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#ae48d4913285518e2c21a3457017e716e">release</a>();</div><div class="line"></div><div class="line">    LOGLN(<span class="stringliteral">&quot;Finding features, time: &quot;</span> &lt;&lt; ((<a class="code" href="../../db/de0/group__core__utils.html#gae73f58000611a1af25dd36d496bf4487">getTickCount</a>() - t) / <a name="a17"></a><a class="code" href="../../db/de0/group__core__utils.html#ga705441a9ef01f47acdc55d87fbe5090c">getTickFrequency</a>()) &lt;&lt; <span class="stringliteral">&quot; sec&quot;</span>);</div><div class="line"></div><div class="line">    LOG(<span class="stringliteral">&quot;Pairwise matching&quot;</span>);</div><div class="line"><span class="preprocessor">#if ENABLE_LOG</span></div><div class="line">    t = <a class="code" href="../../db/de0/group__core__utils.html#gae73f58000611a1af25dd36d496bf4487">getTickCount</a>();</div><div class="line"><span class="preprocessor">#endif</span></div><div class="line">    vector&lt;MatchesInfo&gt; pairwise_matches;</div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga6395ca871a678020c4a31fadf7e8cc63">Ptr&lt;FeaturesMatcher&gt;</a> matcher;</div><div class="line">    <span class="keywordflow">if</span> (matcher_type == <span class="stringliteral">&quot;affine&quot;</span>)</div><div class="line">        matcher = makePtr&lt;AffineBestOf2NearestMatcher&gt;(<span class="keyword">false</span>, try_cuda, match_conf);</div><div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (range_width==-1)</div><div class="line">        matcher = makePtr&lt;BestOf2NearestMatcher&gt;(try_cuda, match_conf);</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">        matcher = makePtr&lt;BestOf2NearestRangeMatcher&gt;(range_width, try_cuda, match_conf);</div><div class="line"></div><div class="line">    (*matcher)(features, pairwise_matches);</div><div class="line">    matcher-&gt;collectGarbage();</div><div class="line"></div><div class="line">    LOGLN(<span class="stringliteral">&quot;Pairwise matching, time: &quot;</span> &lt;&lt; ((<a class="code" href="../../db/de0/group__core__utils.html#gae73f58000611a1af25dd36d496bf4487">getTickCount</a>() - t) / <a class="code" href="../../db/de0/group__core__utils.html#ga705441a9ef01f47acdc55d87fbe5090c">getTickFrequency</a>()) &lt;&lt; <span class="stringliteral">&quot; sec&quot;</span>);</div><div class="line"></div><div class="line">    <span class="comment">// Check if we should save matches graph</span></div><div class="line">    <span class="keywordflow">if</span> (save_graph)</div><div class="line">    {</div><div class="line">        LOGLN(<span class="stringliteral">&quot;Saving matches graph...&quot;</span>);</div><div class="line">        ofstream f(save_graph_to.c_str());</div><div class="line">        f &lt;&lt; <a name="a18"></a><a class="code" href="../../d7/d74/group__stitching__rotation.html#gabaeb9dab170ea8066ae2583bf3a669e9">matchesGraphAsString</a>(img_names, pairwise_matches, conf_thresh);</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="comment">// Leave only images we are sure are from the same panorama</span></div><div class="line">    vector&lt;int&gt; indices = <a name="a19"></a><a class="code" href="../../d7/d74/group__stitching__rotation.html#ga855d2fccbcfc3b3477b34d415be5e786">leaveBiggestComponent</a>(features, pairwise_matches, conf_thresh);</div><div class="line">    vector&lt;Mat&gt; img_subset;</div><div class="line">    vector&lt;String&gt; img_names_subset;</div><div class="line">    vector&lt;Size&gt; full_img_sizes_subset;</div><div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; indices.size(); ++i)</div><div class="line">    {</div><div class="line">        img_names_subset.push_back(img_names[indices[i]]);</div><div class="line">        img_subset.push_back(images[indices[i]]);</div><div class="line">        full_img_sizes_subset.push_back(full_img_sizes[indices[i]]);</div><div class="line">    }</div><div class="line"></div><div class="line">    images = img_subset;</div><div class="line">    img_names = img_names_subset;</div><div class="line">    full_img_sizes = full_img_sizes_subset;</div><div class="line"></div><div class="line">    <span class="comment">// Check if we still have enough images</span></div><div class="line">    num_images = <span class="keyword">static_cast&lt;</span><span class="keywordtype">int</span><span class="keyword">&gt;</span>(img_names.size());</div><div class="line">    <span class="keywordflow">if</span> (num_images &lt; 2)</div><div class="line">    {</div><div class="line">        LOGLN(<span class="stringliteral">&quot;Need more images&quot;</span>);</div><div class="line">        <span class="keywordflow">return</span> -1;</div><div class="line">    }</div><div class="line"></div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga6395ca871a678020c4a31fadf7e8cc63">Ptr&lt;Estimator&gt;</a> estimator;</div><div class="line">    <span class="keywordflow">if</span> (estimator_type == <span class="stringliteral">&quot;affine&quot;</span>)</div><div class="line">        estimator = makePtr&lt;AffineBasedEstimator&gt;();</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">        estimator = makePtr&lt;HomographyBasedEstimator&gt;();</div><div class="line"></div><div class="line">    vector&lt;CameraParams&gt; cameras;</div><div class="line">    <span class="keywordflow">if</span> (!(*estimator)(features, pairwise_matches, cameras))</div><div class="line">    {</div><div class="line">        cout &lt;&lt; <span class="stringliteral">&quot;Homography estimation failed.\n&quot;</span>;</div><div class="line">        <span class="keywordflow">return</span> -1;</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; cameras.size(); ++i)</div><div class="line">    {</div><div class="line">        <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> R;</div><div class="line">        cameras[i].R.<a name="a20"></a><a class="code" href="../../d3/d63/classcv_1_1Mat.html#adf88c60c5b4980e05bb556080916978b">convertTo</a>(R, <a name="a21"></a><a class="code" href="../../d1/d1b/group__core__hal__interface.html#ga4a3def5d72b74bed31f5f8ab7676099c">CV_32F</a>);</div><div class="line">        cameras[i].R = R;</div><div class="line">        LOGLN(<span class="stringliteral">&quot;Initial camera intrinsics #&quot;</span> &lt;&lt; indices[i]+1 &lt;&lt; <span class="stringliteral">&quot;:\nK:\n&quot;</span> &lt;&lt; cameras[i].K() &lt;&lt; <span class="stringliteral">&quot;\nR:\n&quot;</span> &lt;&lt; cameras[i].R);</div><div class="line">    }</div><div class="line"></div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga6395ca871a678020c4a31fadf7e8cc63">Ptr&lt;detail::BundleAdjusterBase&gt;</a> adjuster;</div><div class="line">    <span class="keywordflow">if</span> (ba_cost_func == <span class="stringliteral">&quot;reproj&quot;</span>) adjuster = makePtr&lt;detail::BundleAdjusterReproj&gt;();</div><div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ba_cost_func == <span class="stringliteral">&quot;ray&quot;</span>) adjuster = makePtr&lt;detail::BundleAdjusterRay&gt;();</div><div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ba_cost_func == <span class="stringliteral">&quot;affine&quot;</span>) adjuster = makePtr&lt;detail::BundleAdjusterAffinePartial&gt;();</div><div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ba_cost_func == <span class="stringliteral">&quot;no&quot;</span>) adjuster = makePtr&lt;NoBundleAdjuster&gt;();</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        cout &lt;&lt; <span class="stringliteral">&quot;Unknown bundle adjustment cost function: &#39;&quot;</span> &lt;&lt; ba_cost_func &lt;&lt; <span class="stringliteral">&quot;&#39;.\n&quot;</span>;</div><div class="line">        <span class="keywordflow">return</span> -1;</div><div class="line">    }</div><div class="line">    adjuster-&gt;setConfThresh(conf_thresh);</div><div class="line">    <a name="_a22"></a><a class="code" href="../../df/dfc/classcv_1_1Mat__.html">Mat_&lt;uchar&gt;</a> refine_mask = Mat::zeros(3, 3, <a name="a23"></a><a class="code" href="../../d1/d1b/group__core__hal__interface.html#ga32b18d904ee2b1731a9416a8eef67d06">CV_8U</a>);</div><div class="line">    <span class="keywordflow">if</span> (ba_refine_mask[0] == <span class="charliteral">&#39;x&#39;</span>) refine_mask(0,0) = 1;</div><div class="line">    <span class="keywordflow">if</span> (ba_refine_mask[1] == <span class="charliteral">&#39;x&#39;</span>) refine_mask(0,1) = 1;</div><div class="line">    <span class="keywordflow">if</span> (ba_refine_mask[2] == <span class="charliteral">&#39;x&#39;</span>) refine_mask(0,2) = 1;</div><div class="line">    <span class="keywordflow">if</span> (ba_refine_mask[3] == <span class="charliteral">&#39;x&#39;</span>) refine_mask(1,1) = 1;</div><div class="line">    <span class="keywordflow">if</span> (ba_refine_mask[4] == <span class="charliteral">&#39;x&#39;</span>) refine_mask(1,2) = 1;</div><div class="line">    adjuster-&gt;setRefinementMask(refine_mask);</div><div class="line">    <span class="keywordflow">if</span> (!(*adjuster)(features, pairwise_matches, cameras))</div><div class="line">    {</div><div class="line">        cout &lt;&lt; <span class="stringliteral">&quot;Camera parameters adjusting failed.\n&quot;</span>;</div><div class="line">        <span class="keywordflow">return</span> -1;</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="comment">// Find median focal length</span></div><div class="line"></div><div class="line">    vector&lt;double&gt; focals;</div><div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; cameras.size(); ++i)</div><div class="line">    {</div><div class="line">        LOGLN(<span class="stringliteral">&quot;Camera #&quot;</span> &lt;&lt; indices[i]+1 &lt;&lt; <span class="stringliteral">&quot;:\nK:\n&quot;</span> &lt;&lt; cameras[i].K() &lt;&lt; <span class="stringliteral">&quot;\nR:\n&quot;</span> &lt;&lt; cameras[i].R);</div><div class="line">        focals.push_back(cameras[i].focal);</div><div class="line">    }</div><div class="line"></div><div class="line">    <a name="a24"></a><a class="code" href="../../d2/de8/group__core__array.html#ga45dd56da289494ce874be2324856898f">sort</a>(focals.begin(), focals.end());</div><div class="line">    <span class="keywordtype">float</span> warped_image_scale;</div><div class="line">    <span class="keywordflow">if</span> (focals.size() % 2 == 1)</div><div class="line">        warped_image_scale = static_cast&lt;float&gt;(focals[focals.size() / 2]);</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">        warped_image_scale = <span class="keyword">static_cast&lt;</span><span class="keywordtype">float</span><span class="keyword">&gt;</span>(focals[focals.size() / 2 - 1] + focals[focals.size() / 2]) * 0.5f;</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (do_wave_correct)</div><div class="line">    {</div><div class="line">        vector&lt;Mat&gt; rmats;</div><div class="line">        <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; cameras.size(); ++i)</div><div class="line">            rmats.push_back(cameras[i].R.clone());</div><div class="line">        <a name="a25"></a><a class="code" href="../../d7/d74/group__stitching__rotation.html#ga8faf9588aebd5aeb6f8c649c82beb1fb">waveCorrect</a>(rmats, wave_correct);</div><div class="line">        <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; cameras.size(); ++i)</div><div class="line">            cameras[i].R = rmats[i];</div><div class="line">    }</div><div class="line"></div><div class="line">    LOGLN(<span class="stringliteral">&quot;Warping images (auxiliary)... &quot;</span>);</div><div class="line"><span class="preprocessor">#if ENABLE_LOG</span></div><div class="line">    t = <a class="code" href="../../db/de0/group__core__utils.html#gae73f58000611a1af25dd36d496bf4487">getTickCount</a>();</div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"></div><div class="line">    vector&lt;Point&gt; corners(num_images);</div><div class="line">    vector&lt;UMat&gt; masks_warped(num_images);</div><div class="line">    vector&lt;UMat&gt; images_warped(num_images);</div><div class="line">    vector&lt;Size&gt; sizes(num_images);</div><div class="line">    vector&lt;UMat&gt; masks(num_images);</div><div class="line"></div><div class="line">    <span class="comment">// Prepare images masks</span></div><div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; num_images; ++i)</div><div class="line">    {</div><div class="line">        masks[i].create(images[i].<a name="a26"></a><a class="code" href="../../df/d5b/namespacecv_1_1gapi_1_1streaming.html#a0a915e69f4cc8284293e40fc9ffbf157">size</a>(), <a class="code" href="../../d1/d1b/group__core__hal__interface.html#ga32b18d904ee2b1731a9416a8eef67d06">CV_8U</a>);</div><div class="line">        masks[i].setTo(Scalar::all(255));</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="comment">// Warp images and their masks</span></div><div class="line"></div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga6395ca871a678020c4a31fadf7e8cc63">Ptr&lt;WarperCreator&gt;</a> warper_creator;</div><div class="line"><span class="preprocessor">#ifdef HAVE_OPENCV_CUDAWARPING</span></div><div class="line">    <span class="keywordflow">if</span> (try_cuda &amp;&amp; <a name="a27"></a><a class="code" href="../../d8/d40/group__cudacore__init.html#gaaa93892f9189163e5d53790b4b1e88db">cuda::getCudaEnabledDeviceCount</a>() &gt; 0)</div><div class="line">    {</div><div class="line">        <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;plane&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::PlaneWarperGpu&gt;();</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;cylindrical&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::CylindricalWarperGpu&gt;();</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;spherical&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::SphericalWarperGpu&gt;();</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line"><span class="preprocessor">#endif</span></div><div class="line">    {</div><div class="line">        <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;plane&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::PlaneWarper&gt;();</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;affine&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::AffineWarper&gt;();</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;cylindrical&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::CylindricalWarper&gt;();</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;spherical&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::SphericalWarper&gt;();</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;fisheye&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::FisheyeWarper&gt;();</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;stereographic&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::StereographicWarper&gt;();</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;compressedPlaneA2B1&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::CompressedRectilinearWarper&gt;(2.0f, 1.0f);</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;compressedPlaneA1.5B1&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::CompressedRectilinearWarper&gt;(1.5f, 1.0f);</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;compressedPlanePortraitA2B1&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::CompressedRectilinearPortraitWarper&gt;(2.0f, 1.0f);</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;compressedPlanePortraitA1.5B1&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::CompressedRectilinearPortraitWarper&gt;(1.5f, 1.0f);</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;paniniA2B1&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::PaniniWarper&gt;(2.0f, 1.0f);</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;paniniA1.5B1&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::PaniniWarper&gt;(1.5f, 1.0f);</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;paniniPortraitA2B1&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::PaniniPortraitWarper&gt;(2.0f, 1.0f);</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;paniniPortraitA1.5B1&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::PaniniPortraitWarper&gt;(1.5f, 1.0f);</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;mercator&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::MercatorWarper&gt;();</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (warp_type == <span class="stringliteral">&quot;transverseMercator&quot;</span>)</div><div class="line">            warper_creator = makePtr&lt;cv::TransverseMercatorWarper&gt;();</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (!warper_creator)</div><div class="line">    {</div><div class="line">        cout &lt;&lt; <span class="stringliteral">&quot;Can&#39;t create the following warper &#39;&quot;</span> &lt;&lt; warp_type &lt;&lt; <span class="stringliteral">&quot;&#39;\n&quot;</span>;</div><div class="line">        <span class="keywordflow">return</span> 1;</div><div class="line">    }</div><div class="line"></div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga6395ca871a678020c4a31fadf7e8cc63">Ptr&lt;RotationWarper&gt;</a> warper = warper_creator-&gt;create(static_cast&lt;float&gt;(warped_image_scale * seam_work_aspect));</div><div class="line"></div><div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; num_images; ++i)</div><div class="line">    {</div><div class="line">        <a name="_a28"></a><a class="code" href="../../df/dfc/classcv_1_1Mat__.html">Mat_&lt;float&gt;</a> K;</div><div class="line">        cameras[i].K().<a class="code" href="../../d3/d63/classcv_1_1Mat.html#adf88c60c5b4980e05bb556080916978b">convertTo</a>(K, <a class="code" href="../../d1/d1b/group__core__hal__interface.html#ga4a3def5d72b74bed31f5f8ab7676099c">CV_32F</a>);</div><div class="line">        <span class="keywordtype">float</span> swa = (float)seam_work_aspect;</div><div class="line">        K(0,0) *= swa; K(0,2) *= swa;</div><div class="line">        K(1,1) *= swa; K(1,2) *= swa;</div><div class="line"></div><div class="line">        corners[i] = warper-&gt;warp(images[i], K, cameras[i].R, <a name="a29"></a><a class="code" href="../../da/d54/group__imgproc__transform.html#gga5bb5a1fea74ea38e1a5445ca803ff121ac97d8e4880d8b5d509e96825c7522deb">INTER_LINEAR</a>, <a name="a30"></a><a class="code" href="../../d2/de8/group__core__array.html#gga209f2f4869e304c82d07739337eae7c5a815c8a89b7cb206dcba14d11b7560f4b">BORDER_REFLECT</a>, images_warped[i]);</div><div class="line">        sizes[i] = images_warped[i].size();</div><div class="line"></div><div class="line">        warper-&gt;warp(masks[i], K, cameras[i].R, <a name="a31"></a><a class="code" href="../../da/d54/group__imgproc__transform.html#gga5bb5a1fea74ea38e1a5445ca803ff121aa5521d8e080972c762467c45f3b70e6c">INTER_NEAREST</a>, <a name="a32"></a><a class="code" href="../../d2/de8/group__core__array.html#gga209f2f4869e304c82d07739337eae7c5aed2e4346047e265c8c5a6d0276dcd838">BORDER_CONSTANT</a>, masks_warped[i]);</div><div class="line">    }</div><div class="line"></div><div class="line">    vector&lt;UMat&gt; images_warped_f(num_images);</div><div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; num_images; ++i)</div><div class="line">        images_warped[i].<a name="a33"></a><a class="code" href="../../d6/d91/group__gapi__transform.html#gae972b2c91904d36e92ee14a6778db82e">convertTo</a>(images_warped_f[i], <a class="code" href="../../d1/d1b/group__core__hal__interface.html#ga4a3def5d72b74bed31f5f8ab7676099c">CV_32F</a>);</div><div class="line"></div><div class="line">    LOGLN(<span class="stringliteral">&quot;Warping images, time: &quot;</span> &lt;&lt; ((<a class="code" href="../../db/de0/group__core__utils.html#gae73f58000611a1af25dd36d496bf4487">getTickCount</a>() - t) / <a class="code" href="../../db/de0/group__core__utils.html#ga705441a9ef01f47acdc55d87fbe5090c">getTickFrequency</a>()) &lt;&lt; <span class="stringliteral">&quot; sec&quot;</span>);</div><div class="line"></div><div class="line">    LOGLN(<span class="stringliteral">&quot;Compensating exposure...&quot;</span>);</div><div class="line"><span class="preprocessor">#if ENABLE_LOG</span></div><div class="line">    t = <a class="code" href="../../db/de0/group__core__utils.html#gae73f58000611a1af25dd36d496bf4487">getTickCount</a>();</div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"></div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga6395ca871a678020c4a31fadf7e8cc63">Ptr&lt;ExposureCompensator&gt;</a> compensator = ExposureCompensator::createDefault(expos_comp_type);</div><div class="line">    <span class="keywordflow">if</span> (dynamic_cast&lt;GainCompensator*&gt;(compensator.get()))</div><div class="line">    {</div><div class="line">        <a name="_a34"></a><a class="code" href="../../d0/de1/classcv_1_1detail_1_1GainCompensator.html">GainCompensator</a>* gcompensator = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="../../d0/de1/classcv_1_1detail_1_1GainCompensator.html">GainCompensator</a>*<span class="keyword">&gt;</span>(compensator.get());</div><div class="line">        gcompensator-&gt;<a name="a35"></a><a class="code" href="../../d0/de1/classcv_1_1detail_1_1GainCompensator.html#aa1b612c1f334592c084cdf057ce15805">setNrFeeds</a>(expos_comp_nr_feeds);</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (dynamic_cast&lt;ChannelsCompensator*&gt;(compensator.get()))</div><div class="line">    {</div><div class="line">        <a name="_a36"></a><a class="code" href="../../d4/ddd/classcv_1_1detail_1_1ChannelsCompensator.html">ChannelsCompensator</a>* ccompensator = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="../../d4/ddd/classcv_1_1detail_1_1ChannelsCompensator.html">ChannelsCompensator</a>*<span class="keyword">&gt;</span>(compensator.get());</div><div class="line">        ccompensator-&gt;<a name="a37"></a><a class="code" href="../../d4/ddd/classcv_1_1detail_1_1ChannelsCompensator.html#a0e88972a7011b2a112e4fe20346d4f35">setNrFeeds</a>(expos_comp_nr_feeds);</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (dynamic_cast&lt;BlocksCompensator*&gt;(compensator.get()))</div><div class="line">    {</div><div class="line">        <a name="_a38"></a><a class="code" href="../../da/df4/classcv_1_1detail_1_1BlocksCompensator.html">BlocksCompensator</a>* bcompensator = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="../../da/df4/classcv_1_1detail_1_1BlocksCompensator.html">BlocksCompensator</a>*<span class="keyword">&gt;</span>(compensator.get());</div><div class="line">        bcompensator-&gt;<a name="a39"></a><a class="code" href="../../da/df4/classcv_1_1detail_1_1BlocksCompensator.html#a2764dddb47b321b5c66b33b28f4e8571">setNrFeeds</a>(expos_comp_nr_feeds);</div><div class="line">        bcompensator-&gt;<a name="a40"></a><a class="code" href="../../da/df4/classcv_1_1detail_1_1BlocksCompensator.html#a96056be42faacbbc90c88d1a933f732c">setNrGainsFilteringIterations</a>(expos_comp_nr_filtering);</div><div class="line">        bcompensator-&gt;<a name="a41"></a><a class="code" href="../../da/df4/classcv_1_1detail_1_1BlocksCompensator.html#a2100042d80ccf54b18d6513afff5a731">setBlockSize</a>(expos_comp_block_size, expos_comp_block_size);</div><div class="line">    }</div><div class="line"></div><div class="line">    compensator-&gt;feed(corners, images_warped, masks_warped);</div><div class="line"></div><div class="line">    LOGLN(<span class="stringliteral">&quot;Compensating exposure, time: &quot;</span> &lt;&lt; ((<a class="code" href="../../db/de0/group__core__utils.html#gae73f58000611a1af25dd36d496bf4487">getTickCount</a>() - t) / <a class="code" href="../../db/de0/group__core__utils.html#ga705441a9ef01f47acdc55d87fbe5090c">getTickFrequency</a>()) &lt;&lt; <span class="stringliteral">&quot; sec&quot;</span>);</div><div class="line"></div><div class="line">    LOGLN(<span class="stringliteral">&quot;Finding seams...&quot;</span>);</div><div class="line"><span class="preprocessor">#if ENABLE_LOG</span></div><div class="line">    t = <a class="code" href="../../db/de0/group__core__utils.html#gae73f58000611a1af25dd36d496bf4487">getTickCount</a>();</div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"></div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga6395ca871a678020c4a31fadf7e8cc63">Ptr&lt;SeamFinder&gt;</a> seam_finder;</div><div class="line">    <span class="keywordflow">if</span> (seam_find_type == <span class="stringliteral">&quot;no&quot;</span>)</div><div class="line">        seam_finder = makePtr&lt;detail::NoSeamFinder&gt;();</div><div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (seam_find_type == <span class="stringliteral">&quot;voronoi&quot;</span>)</div><div class="line">        seam_finder = makePtr&lt;detail::VoronoiSeamFinder&gt;();</div><div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (seam_find_type == <span class="stringliteral">&quot;gc_color&quot;</span>)</div><div class="line">    {</div><div class="line"><span class="preprocessor">#ifdef HAVE_OPENCV_CUDALEGACY</span></div><div class="line">        <span class="keywordflow">if</span> (try_cuda &amp;&amp; <a class="code" href="../../d8/d40/group__cudacore__init.html#gaaa93892f9189163e5d53790b4b1e88db">cuda::getCudaEnabledDeviceCount</a>() &gt; 0)</div><div class="line">            seam_finder = makePtr&lt;detail::GraphCutSeamFinderGpu&gt;(GraphCutSeamFinderBase::COST_COLOR);</div><div class="line">        <span class="keywordflow">else</span></div><div class="line"><span class="preprocessor">#endif</span></div><div class="line">            seam_finder = makePtr&lt;detail::GraphCutSeamFinder&gt;(GraphCutSeamFinderBase::COST_COLOR);</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (seam_find_type == <span class="stringliteral">&quot;gc_colorgrad&quot;</span>)</div><div class="line">    {</div><div class="line"><span class="preprocessor">#ifdef HAVE_OPENCV_CUDALEGACY</span></div><div class="line">        <span class="keywordflow">if</span> (try_cuda &amp;&amp; <a class="code" href="../../d8/d40/group__cudacore__init.html#gaaa93892f9189163e5d53790b4b1e88db">cuda::getCudaEnabledDeviceCount</a>() &gt; 0)</div><div class="line">            seam_finder = makePtr&lt;detail::GraphCutSeamFinderGpu&gt;(GraphCutSeamFinderBase::COST_COLOR_GRAD);</div><div class="line">        <span class="keywordflow">else</span></div><div class="line"><span class="preprocessor">#endif</span></div><div class="line">            seam_finder = makePtr&lt;detail::GraphCutSeamFinder&gt;(GraphCutSeamFinderBase::COST_COLOR_GRAD);</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (seam_find_type == <span class="stringliteral">&quot;dp_color&quot;</span>)</div><div class="line">        seam_finder = makePtr&lt;detail::DpSeamFinder&gt;(DpSeamFinder::COLOR);</div><div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (seam_find_type == <span class="stringliteral">&quot;dp_colorgrad&quot;</span>)</div><div class="line">        seam_finder = makePtr&lt;detail::DpSeamFinder&gt;(DpSeamFinder::COLOR_GRAD);</div><div class="line">    <span class="keywordflow">if</span> (!seam_finder)</div><div class="line">    {</div><div class="line">        cout &lt;&lt; <span class="stringliteral">&quot;Can&#39;t create the following seam finder &#39;&quot;</span> &lt;&lt; seam_find_type &lt;&lt; <span class="stringliteral">&quot;&#39;\n&quot;</span>;</div><div class="line">        <span class="keywordflow">return</span> 1;</div><div class="line">    }</div><div class="line"></div><div class="line">    seam_finder-&gt;find(images_warped_f, corners, masks_warped);</div><div class="line"></div><div class="line">    LOGLN(<span class="stringliteral">&quot;Finding seams, time: &quot;</span> &lt;&lt; ((<a class="code" href="../../db/de0/group__core__utils.html#gae73f58000611a1af25dd36d496bf4487">getTickCount</a>() - t) / <a class="code" href="../../db/de0/group__core__utils.html#ga705441a9ef01f47acdc55d87fbe5090c">getTickFrequency</a>()) &lt;&lt; <span class="stringliteral">&quot; sec&quot;</span>);</div><div class="line"></div><div class="line">    <span class="comment">// Release unused memory</span></div><div class="line">    images.clear();</div><div class="line">    images_warped.clear();</div><div class="line">    images_warped_f.clear();</div><div class="line">    masks.clear();</div><div class="line"></div><div class="line">    LOGLN(<span class="stringliteral">&quot;Compositing...&quot;</span>);</div><div class="line"><span class="preprocessor">#if ENABLE_LOG</span></div><div class="line">    t = <a class="code" href="../../db/de0/group__core__utils.html#gae73f58000611a1af25dd36d496bf4487">getTickCount</a>();</div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"></div><div class="line">    <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> img_warped, img_warped_s;</div><div class="line">    <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> dilated_mask, seam_mask, <a name="a42"></a><a class="code" href="../../da/dd3/group__gapi__math.html#gaba076d51941328cb7ca9348b7b535220">mask</a>, mask_warped;</div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga6395ca871a678020c4a31fadf7e8cc63">Ptr&lt;Blender&gt;</a> blender;</div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga6395ca871a678020c4a31fadf7e8cc63">Ptr&lt;Timelapser&gt;</a> timelapser;</div><div class="line">    <span class="comment">//double compose_seam_aspect = 1;</span></div><div class="line">    <span class="keywordtype">double</span> compose_work_aspect = 1;</div><div class="line"></div><div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> img_idx = 0; img_idx &lt; num_images; ++img_idx)</div><div class="line">    {</div><div class="line">        LOGLN(<span class="stringliteral">&quot;Compositing image #&quot;</span> &lt;&lt; indices[img_idx]+1);</div><div class="line"></div><div class="line">        <span class="comment">// Read image and resize it if necessary</span></div><div class="line">        full_img = <a class="code" href="../../d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56">imread</a>(<a class="code" href="../../d6/dba/group__core__utils__samples.html#ga3a33b00033b46c698ff6340d95569c13">samples::findFile</a>(img_names[img_idx]));</div><div class="line">        <span class="keywordflow">if</span> (!is_compose_scale_set)</div><div class="line">        {</div><div class="line">            <span class="keywordflow">if</span> (compose_megapix &gt; 0)</div><div class="line">                compose_scale = <a class="code" href="../../d7/dcc/group__core__utils__softfloat.html#gac48df53b8fd34b87e7b121fa8fd4c379">min</a>(1.0, <a class="code" href="../../d0/de1/group__core.html#ga9070b6a3f093dd952d973819b06f4906">sqrt</a>(compose_megapix * 1e6 / full_img.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#a146f8e8dda07d1365a575ab83d9828d1">size</a>().area()));</div><div class="line">            is_compose_scale_set = <span class="keyword">true</span>;</div><div class="line"></div><div class="line">            <span class="comment">// Compute relative scales</span></div><div class="line">            <span class="comment">//compose_seam_aspect = compose_scale / seam_scale;</span></div><div class="line">            compose_work_aspect = compose_scale / work_scale;</div><div class="line"></div><div class="line">            <span class="comment">// Update warped image scale</span></div><div class="line">            warped_image_scale *= <span class="keyword">static_cast&lt;</span><span class="keywordtype">float</span><span class="keyword">&gt;</span>(compose_work_aspect);</div><div class="line">            warper = warper_creator-&gt;create(warped_image_scale);</div><div class="line"></div><div class="line">            <span class="comment">// Update corners and sizes</span></div><div class="line">            <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; num_images; ++i)</div><div class="line">            {</div><div class="line">                <span class="comment">// Update intrinsics</span></div><div class="line">                cameras[i].focal *= compose_work_aspect;</div><div class="line">                cameras[i].ppx *= compose_work_aspect;</div><div class="line">                cameras[i].ppy *= compose_work_aspect;</div><div class="line"></div><div class="line">                <span class="comment">// Update corner and size</span></div><div class="line">                <a name="_a43"></a><a class="code" href="../../d6/d50/classcv_1_1Size__.html">Size</a> sz = full_img_sizes[i];</div><div class="line">                <span class="keywordflow">if</span> (<a name="a44"></a><a class="code" href="../../d2/d75/namespacecv.html#af6df65b17fb11af6d34634b6dfa44683">std::abs</a>(compose_scale - 1) &gt; 1e-1)</div><div class="line">                {</div><div class="line">                    sz.<a name="a45"></a><a class="code" href="../../d6/d50/classcv_1_1Size__.html#abfe0367b32c407ddccf5ddf92667c73d">width</a> = <a name="a46"></a><a class="code" href="../../db/de0/group__core__utils.html#ga085eca238176984a0b72df2818598d85">cvRound</a>(full_img_sizes[i].width * compose_scale);</div><div class="line">                    sz.<a name="a47"></a><a class="code" href="../../d6/d50/classcv_1_1Size__.html#a1d289dce6b5d8006a54f3ee0259fc545">height</a> = <a class="code" href="../../db/de0/group__core__utils.html#ga085eca238176984a0b72df2818598d85">cvRound</a>(full_img_sizes[i].height * compose_scale);</div><div class="line">                }</div><div class="line"></div><div class="line">                <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> K;</div><div class="line">                cameras[i].K().<a class="code" href="../../d3/d63/classcv_1_1Mat.html#adf88c60c5b4980e05bb556080916978b">convertTo</a>(K, <a class="code" href="../../d1/d1b/group__core__hal__interface.html#ga4a3def5d72b74bed31f5f8ab7676099c">CV_32F</a>);</div><div class="line">                <a name="_a48"></a><a class="code" href="../../d2/d44/classcv_1_1Rect__.html">Rect</a> roi = warper-&gt;warpRoi(sz, K, cameras[i].R);</div><div class="line">                corners[i] = roi.<a name="a49"></a><a class="code" href="../../d2/d44/classcv_1_1Rect__.html#a20dadc5ad7d91a438a4418521760b287">tl</a>();</div><div class="line">                sizes[i] = roi.<a name="a50"></a><a class="code" href="../../d2/d44/classcv_1_1Rect__.html#ab0c92d80e25e22be48c0110c5200da1e">size</a>();</div><div class="line">            }</div><div class="line">        }</div><div class="line">        <span class="keywordflow">if</span> (<a class="code" href="../../d2/d75/namespacecv.html#af6df65b17fb11af6d34634b6dfa44683">abs</a>(compose_scale - 1) &gt; 1e-1)</div><div class="line">            <a class="code" href="../../d5/df1/group__imgproc__hal__functions.html#ga2fe39d2201b12e1b961ca56b2aff9ff2">resize</a>(full_img, img, <a class="code" href="../../dc/d84/group__core__basic.html#ga346f563897249351a34549137c8532a0">Size</a>(), compose_scale, compose_scale, <a class="code" href="../../da/d54/group__imgproc__transform.html#gga5bb5a1fea74ea38e1a5445ca803ff121ac00f4a8155563cdc23437fc0959da935">INTER_LINEAR_EXACT</a>);</div><div class="line">        <span class="keywordflow">else</span></div><div class="line">            img = full_img;</div><div class="line">        full_img.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#ae48d4913285518e2c21a3457017e716e">release</a>();</div><div class="line">        <a class="code" href="../../d6/d50/classcv_1_1Size__.html">Size</a> img_size = img.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#a146f8e8dda07d1365a575ab83d9828d1">size</a>();</div><div class="line"></div><div class="line">        <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> K;</div><div class="line">        cameras[img_idx].K().<a class="code" href="../../d3/d63/classcv_1_1Mat.html#adf88c60c5b4980e05bb556080916978b">convertTo</a>(K, <a class="code" href="../../d1/d1b/group__core__hal__interface.html#ga4a3def5d72b74bed31f5f8ab7676099c">CV_32F</a>);</div><div class="line"></div><div class="line">        <span class="comment">// Warp the current image</span></div><div class="line">        warper-&gt;warp(img, K, cameras[img_idx].R, <a class="code" href="../../da/d54/group__imgproc__transform.html#gga5bb5a1fea74ea38e1a5445ca803ff121ac97d8e4880d8b5d509e96825c7522deb">INTER_LINEAR</a>, <a class="code" href="../../d2/de8/group__core__array.html#gga209f2f4869e304c82d07739337eae7c5a815c8a89b7cb206dcba14d11b7560f4b">BORDER_REFLECT</a>, img_warped);</div><div class="line"></div><div class="line">        <span class="comment">// Warp the current image mask</span></div><div class="line">        mask.<a name="a51"></a><a class="code" href="../../d3/d63/classcv_1_1Mat.html#a55ced2c8d844d683ea9a725c60037ad0">create</a>(img_size, <a class="code" href="../../d1/d1b/group__core__hal__interface.html#ga32b18d904ee2b1731a9416a8eef67d06">CV_8U</a>);</div><div class="line">        mask.<a name="a52"></a><a class="code" href="../../d3/d63/classcv_1_1Mat.html#a0440e2a164c0b0d8462fb1e487be9876">setTo</a>(Scalar::all(255));</div><div class="line">        warper-&gt;warp(mask, K, cameras[img_idx].R, <a class="code" href="../../da/d54/group__imgproc__transform.html#gga5bb5a1fea74ea38e1a5445ca803ff121aa5521d8e080972c762467c45f3b70e6c">INTER_NEAREST</a>, <a class="code" href="../../d2/de8/group__core__array.html#gga209f2f4869e304c82d07739337eae7c5aed2e4346047e265c8c5a6d0276dcd838">BORDER_CONSTANT</a>, mask_warped);</div><div class="line"></div><div class="line">        <span class="comment">// Compensate exposure</span></div><div class="line">        compensator-&gt;apply(img_idx, corners[img_idx], img_warped, mask_warped);</div><div class="line"></div><div class="line">        img_warped.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#adf88c60c5b4980e05bb556080916978b">convertTo</a>(img_warped_s, <a name="a53"></a><a class="code" href="../../d1/d1b/group__core__hal__interface.html#ga9d2ee1a8334733dea7482a47a88e0f87">CV_16S</a>);</div><div class="line">        img_warped.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#ae48d4913285518e2c21a3457017e716e">release</a>();</div><div class="line">        img.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#ae48d4913285518e2c21a3457017e716e">release</a>();</div><div class="line">        mask.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#ae48d4913285518e2c21a3457017e716e">release</a>();</div><div class="line"></div><div class="line">        <a name="a54"></a><a class="code" href="../../d4/d86/group__imgproc__filter.html#ga4ff0f3318642c4f469d0e11f242f3b6c">dilate</a>(masks_warped[img_idx], dilated_mask, <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a>());</div><div class="line">        <a class="code" href="../../d5/df1/group__imgproc__hal__functions.html#ga2fe39d2201b12e1b961ca56b2aff9ff2">resize</a>(dilated_mask, seam_mask, mask_warped.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#a146f8e8dda07d1365a575ab83d9828d1">size</a>(), 0, 0, <a class="code" href="../../da/d54/group__imgproc__transform.html#gga5bb5a1fea74ea38e1a5445ca803ff121ac00f4a8155563cdc23437fc0959da935">INTER_LINEAR_EXACT</a>);</div><div class="line">        mask_warped = seam_mask &amp; mask_warped;</div><div class="line"></div><div class="line">        <span class="keywordflow">if</span> (!blender &amp;&amp; !timelapse)</div><div class="line">        {</div><div class="line">            blender = Blender::createDefault(blend_type, try_cuda);</div><div class="line">            <a class="code" href="../../d6/d50/classcv_1_1Size__.html">Size</a> dst_sz = <a name="a55"></a><a class="code" href="../../d1/d46/group__stitching.html#gab7d43257ae6a1d607ee195f369d51b67">resultRoi</a>(corners, sizes).<a class="code" href="../../d2/d44/classcv_1_1Rect__.html#ab0c92d80e25e22be48c0110c5200da1e">size</a>();</div><div class="line">            <span class="keywordtype">float</span> blend_width = <a class="code" href="../../d0/de1/group__core.html#ga9070b6a3f093dd952d973819b06f4906">sqrt</a>(static_cast&lt;float&gt;(dst_sz.<a name="a56"></a><a class="code" href="../../d6/d50/classcv_1_1Size__.html#a8cc3d32e40c9b5324d316c35c4773dff">area</a>())) * blend_strength / 100.f;</div><div class="line">            <span class="keywordflow">if</span> (blend_width &lt; 1.f)</div><div class="line">                blender = Blender::createDefault(Blender::NO, try_cuda);</div><div class="line">            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (blend_type == Blender::MULTI_BAND)</div><div class="line">            {</div><div class="line">                <a name="_a57"></a><a class="code" href="../../d5/d4b/classcv_1_1detail_1_1MultiBandBlender.html">MultiBandBlender</a>* mb = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="../../d5/d4b/classcv_1_1detail_1_1MultiBandBlender.html">MultiBandBlender</a>*<span class="keyword">&gt;</span>(blender.get());</div><div class="line">                mb-&gt;<a name="a58"></a><a class="code" href="../../d5/d4b/classcv_1_1detail_1_1MultiBandBlender.html#a2efd19181426ba017b23c24c88666188">setNumBands</a>(static_cast&lt;int&gt;(ceil(<a name="a59"></a><a class="code" href="../../d0/de1/group__core.html#ga4eba02a849f926ee1764acde47108753">log</a>(blend_width)/<a class="code" href="../../d0/de1/group__core.html#ga4eba02a849f926ee1764acde47108753">log</a>(2.)) - 1.));</div><div class="line">                LOGLN(<span class="stringliteral">&quot;Multi-band blender, number of bands: &quot;</span> &lt;&lt; mb-&gt;<a name="a60"></a><a class="code" href="../../d5/d4b/classcv_1_1detail_1_1MultiBandBlender.html#a150b2708c084e00b107fcc42d0298e98">numBands</a>());</div><div class="line">            }</div><div class="line">            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (blend_type == Blender::FEATHER)</div><div class="line">            {</div><div class="line">                <a name="_a61"></a><a class="code" href="../../d4/d69/classcv_1_1detail_1_1FeatherBlender.html">FeatherBlender</a>* fb = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="../../d4/d69/classcv_1_1detail_1_1FeatherBlender.html">FeatherBlender</a>*<span class="keyword">&gt;</span>(blender.get());</div><div class="line">                fb-&gt;<a name="a62"></a><a class="code" href="../../d4/d69/classcv_1_1detail_1_1FeatherBlender.html#aa4c09de778a01cdad7af1aabc443b279">setSharpness</a>(1.f/blend_width);</div><div class="line">                LOGLN(<span class="stringliteral">&quot;Feather blender, sharpness: &quot;</span> &lt;&lt; fb-&gt;<a name="a63"></a><a class="code" href="../../d4/d69/classcv_1_1detail_1_1FeatherBlender.html#a52175c9bf5fb8ccbe692dcec2f575320">sharpness</a>());</div><div class="line">            }</div><div class="line">            blender-&gt;prepare(corners, sizes);</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!timelapser &amp;&amp; timelapse)</div><div class="line">        {</div><div class="line">            timelapser = Timelapser::createDefault(timelapse_type);</div><div class="line">            timelapser-&gt;initialize(corners, sizes);</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="comment">// Blend the current image</span></div><div class="line">        <span class="keywordflow">if</span> (timelapse)</div><div class="line">        {</div><div class="line">            timelapser-&gt;process(img_warped_s, Mat::ones(img_warped_s.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#a146f8e8dda07d1365a575ab83d9828d1">size</a>(), <a name="a64"></a><a class="code" href="../../d1/d1b/group__core__hal__interface.html#ga81df635441b21f532fdace401e04f588">CV_8UC1</a>), corners[img_idx]);</div><div class="line">            <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> fixedFileName;</div><div class="line">            <span class="keywordtype">size_t</span> pos_s = <a name="a65"></a><a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>(img_names[img_idx]).find_last_of(<span class="stringliteral">&quot;/\\&quot;</span>);</div><div class="line">            <span class="keywordflow">if</span> (pos_s == String::npos)</div><div class="line">            {</div><div class="line">                fixedFileName = <span class="stringliteral">&quot;fixed_&quot;</span> + img_names[img_idx];</div><div class="line">            }</div><div class="line">            <span class="keywordflow">else</span></div><div class="line">            {</div><div class="line">                fixedFileName = <span class="stringliteral">&quot;fixed_&quot;</span> + <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>(img_names[img_idx]).substr(pos_s + 1, <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>(img_names[img_idx]).length() - pos_s);</div><div class="line">            }</div><div class="line">            <a name="a66"></a><a class="code" href="../../d4/da8/group__imgcodecs.html#gabbc7ef1aa2edfaa87772f1202d67e0ce">imwrite</a>(fixedFileName, timelapser-&gt;getDst());</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span></div><div class="line">        {</div><div class="line">            blender-&gt;feed(img_warped_s, mask_warped, corners[img_idx]);</div><div class="line">        }</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (!timelapse)</div><div class="line">    {</div><div class="line">        <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> result, result_mask;</div><div class="line">        blender-&gt;blend(result, result_mask);</div><div class="line"></div><div class="line">        LOGLN(<span class="stringliteral">&quot;Compositing, time: &quot;</span> &lt;&lt; ((<a class="code" href="../../db/de0/group__core__utils.html#gae73f58000611a1af25dd36d496bf4487">getTickCount</a>() - t) / <a class="code" href="../../db/de0/group__core__utils.html#ga705441a9ef01f47acdc55d87fbe5090c">getTickFrequency</a>()) &lt;&lt; <span class="stringliteral">&quot; sec&quot;</span>);</div><div class="line"></div><div class="line">        <a class="code" href="../../d4/da8/group__imgcodecs.html#gabbc7ef1aa2edfaa87772f1202d67e0ce">imwrite</a>(result_name, result);</div><div class="line">    }</div><div class="line"></div><div class="line">    LOGLN(<span class="stringliteral">&quot;Finished, total time: &quot;</span> &lt;&lt; ((<a class="code" href="../../db/de0/group__core__utils.html#gae73f58000611a1af25dd36d496bf4487">getTickCount</a>() - app_start_time) / <a class="code" href="../../db/de0/group__core__utils.html#ga705441a9ef01f47acdc55d87fbe5090c">getTickFrequency</a>()) &lt;&lt; <span class="stringliteral">&quot; sec&quot;</span>);</div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">}</div></div><!-- fragment --> </div><!-- contents -->
<!-- HTML footer for doxygen 1.8.6-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Apr 2 2021 11:36:29 for OpenCV by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="../../doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
<script type="text/javascript">
//<![CDATA[
addTutorialsButtons();
//]]>
</script>
</body>
</html>
